package main

import (
	"flag"
	goConf "github.com/zeromicro/go-zero/core/conf"
	"os"
	"os/signal"
	"shangke-device/app/conf"
	"shangke-device/app/http"
	"shangke-device/app/svcContent"
	yhttp "shangke-device/internal/http"
)

var f = flag.String("f", "config.yaml", "config file")

func main() {
	flag.Parse()
	var c conf.Conf
	goConf.MustLoad(*f, &c)

	svc := svcContent.NewSvc(c)
	httpServer := yhttp.NewServer(c.HttpConf, svc.Log, http.InitRouter(svc))

	httpServer.RegisterCancelServer(svc.Mqtt.Stop)

	quit := make(chan os.Signal)
	signal.Notify(quit, os.Interrupt)

	httpServer.Start(quit)
}
